
mat drop _all

cap ssc install psacalc

* Enter here the effects IN ABSOLUTE TERMS found in most preferred speficication of Table 2
local effect_cog "-0.018"

** Oster 2016

local j 0
foreach lhs in cog {

use "$datapath\001_nlsy_child_mother_`lhs'.dta", clear

drop if hours==2080

** To match numbers in Table 2
replace hours = hours/100

local ++j
regress `lhs' $RHSlist

regress `lhs' $RHSlist ${CONTROLlist_`lhs'}

local i 0
forvalues r=0.5(0.1)1 {

	if `j'==1 mat r_sqd = nullmat(r_sqd) , (`r')
	local ++i
	foreach beta in `effect_`lhs'' {
		
		if `i'==1 mat beta = nullmat(beta) \ `beta'
		
		psacalc delta $RHSlist, beta(`beta') rmax(`r') 
		mat aux = nullmat(aux) \ (`r(delta)')
	}
	
	mat aux2 = nullmat(aux2) , aux
	mat drop aux
}

mat delta = nullmat(delta) \ aux2
mat drop aux2
}
 

mat delta = (., r_sqd ) \ (beta, delta)

mat head = J(1,colsof(delta),.)


drop _all



svmat delta

tostring delta1, replace force format(%8.3f)
tostring delta2 - delta7, replace force format(%8.2f)

replace delta1 = "\$R_{max}$" in 1
replace delta1 = "\$\delta_{Oster}$" in 2

*gen outcome = " "
*replace outcome = "Cognitive" in 2
*replace outcome = "Non Cognitive" in 5

*move outcome delta1

texsave delta? using "$outpath\007_TableAET_Oster.tex", ///
headerlines(" & \multicolumn{5}{c}{True $\beta = `effect_cog'$} ") ///
replace nofix frag  nonames location(H) 


